<?php
/**
* Plugin Name: Hello World 2
* Plugin URI: http://ilikekillnerds.com
* Version: 1.0
* Description: A simple hello world plugin
* Author: Dwayne Charrington
* Author URI: http://ilikekillnerds.com
*/
if ( !class_exists( 'helloworld2' )) {

  class helloworld2{
	public $varx = 'x';
	
    function __construct() {
		
      $widget_options = array( 
        'classname' => 'widget_ultimate_posts', 
        // 'description' => __( 'Displays list of posts with an array of options', 'upw' ) 
      );
		$this->varx = 'y';
		//$this->run();
		//print_r($config);
      $control_options = array();
/*
      $this->WP_Widget( 
        'sticky-posts', 
        __( 'Ultimate Posts', 'upw' ), 
        $widget_options,
        $control_options
      );
*/
      //$this->alt_option_name = 'widget_ultimate_posts';
    }
	
	function run($config = array()){
		print_r($config);
		echo "helloworld2 <br>";
		//echo "X - s fds fsf s f ";
	}
	//show frontend page
    function widget( $args, $instance ) {

      global $post;
      ob_start();
      extract( $args );

      $title = apply_filters( 'widget_title', $instance['title'] );
      $title_link = $instance['title_link'];
      $title_background = $instance['title_background'];
      $number = $instance['number'];
      $types = ($instance['types'] ? explode(',', $instance['types']) : '');

      echo $before_widget;
      if ( $title ) {
		if($title_background)  echo '<div class="widget-title" style="background-color: '.$title_background.'!important;z-index: 9999999;">';
        echo $before_title;
        if ( $title_link ) echo "<a href='$title_link'>";
        echo $title;
		if($postNextCate) echo $nextCateTitle;
        if ( $title_link ) echo "</a>";
			if ( $instance['show_morebutton'] ) : ?>
          <a href="<?php echo $instance['morebutton_url']; ?>" class="button view-more"><?php echo $instance['morebutton_text']; ?></a>
       
        <?php endif;
		
        echo $after_title;
		if($title_background) echo '</div>';
      }
      echo $after_widget;

    }

	//admin update
    function update( $new_instance, $old_instance ) {
      $instance = $old_instance;
      $instance['title'] = strip_tags($new_instance['title'] );
      return $instance;

    }
	
	//admin form
    function form( $instance ) {

      // Set default arguments
      $instance = wp_parse_args( (array) $instance, array(
        'title' => '',
        'title_link' => '' ,
        'title_background' => '' ,
        'show_morebutton' => false
      ) );

      // Or use the instance
      $title  = strip_tags($instance['title']);


      ?>

<p>
        <label for="<?php echo $this->get_field_id( 'title_background' ); ?>"><?php _e( 'Title Background', 'upw' ); ?>:</label>
        <input class="widefat picker-color-field" id="<?php echo $this->get_field_id( 'title_background' ); ?>" name="<?php echo $this->get_field_name( 'title_background' ); ?>" type="text" value="<?php echo $title_background; ?>" />
      </p>
	  

      <?php if ( $instance ) { ?>
 

      <?php

      }

    }

  }

  function init_MY_Widget_HelloWord2() {
    //register_widget( 'MY_Widget_HelloWord2' );
  }

  //add_action( 'widgets_init', 'init_MY_Widget_HelloWord2' );
  
$this->add_action( 'widgets_init', 'helloworld2');
}

